home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / GRAPHICS / 4DXDEMO.ZIP / 4DX.TXT < prev    next >
Encoding:
Text File  |  1995-06-12  |  19.1 KB  |  447 lines

  1.  
  2.  
  3. 4DX Rendering Engine
  4.  
  5.         Thank you for purchasing the 4DX Evaluation kit. This kit is designed
  6.         to help you determine if purchasing the 4DX library is right for you.
  7.         This kit is a complete working version of the 4DX library. With it,
  8.         you can compile, link and run your own applications. However, this is
  9.         only an evaluation  kit. You may not distribute, in any way, any
  10.         application made with this library. The amount of the eval kit will
  11.         be deducted from the price of  the distribution kit, should you decide
  12.         to purchase the library.
  13.  
  14.         Please note that technical support can only be provided by email.
  15.         Please post technical support questions to my compuserve account
  16.         at 74774,2475. For support through the internet, the address is
  17.         74774.2475@compuserve.com.
  18.  
  19. 4DX FAQ
  20.  
  21.         What is the 4DX library?
  22.  
  23.         The 4DX library is a rendering engine for creating 3D games.
  24.         It is not a complete game system. The 4DX library uses a series
  25.         of arrays of Sectors, Vertexes, Linedefs, and Actors to render
  26.         a static scene. It is up to your code to make a game from this
  27.         library.
  28.  
  29.         What is required to compile 4DX?
  30.  
  31.         4DX is a C++ Library and requires Watcom C++ v 10.0.
  32.         4DX will NOT work with straight C. 4DX is fully 32bit.
  33.         The DOS library runs under Dos4gw, and the Windows library
  34.         runs under Windows NT, Windows 95, or Windows 3.11 with Win32s.
  35.         If you want your game to run under Windows 3.11, you MUST ship
  36.         it with Win32s!
  37.  
  38.         What are the requirements to run 4DX?
  39.  
  40.         Currently, the DOS version of 4DX requires 4MB of ram to run.
  41.         However, this does not leave much space for graphics and sound.
  42.         The Windows version of 4DX requires 8MB of ram, and Win32s.
  43.  
  44.         What is Win32s?
  45.  
  46.         Win32s is a 32 bit windows subsystem that allows Windows 3.1 to run
  47.         32 bit Windows NT programs, as long as they only call supported
  48.         functions. When compiling your 4DX application, you will compile
  49.         and link for Windows NT.
  50.  
  51.         What is a Sector?
  52.  
  53.         A sector is a two dimensional enclosed area. Looking at an overhead
  54.         map, each sector is a polygon. Each sector can have different lighting
  55.         attributes, and heights associated with it. The sector is the basic
  56.         unit of differentiating areas within the engine.
  57.  
  58.         What is a Linedef?
  59.  
  60.         The sides of sectors are made up of linedefs. Each line in the
  61.         sector is a linedef. Each linedef has a texture associated with
  62.         its upper portion and its lower portion.
  63.  
  64.         What is an Actor?
  65.  
  66.         An actor is an object that is rendered from a frameinfo. An actor
  67.         can be a monster, or an item like a barrel. An actor has a only
  68.         one x,y coordinate, and is always projected flat, towards the
  69.         viewpoint.
  70.  
  71.         What is a FrameInfo?
  72.  
  73.         A frameinfo structure defines a series of bitmaps describing to
  74.         the renderer how to draw an actor. There is not an interface to
  75.         add frameinfo's. Your program must provide a frameinfo array.
  76.         please see the example code.
  77.  
  78.         What is a Texture?
  79.  
  80.         A texture is used to put a picture on a wall. This picture is composed
  81.         of one or more patches.
  82.  
  83.         What is a Patch?
  84.  
  85.         A patch is a picture unit. for instance, a brick wall texture might
  86.         contain only 1 patch, the patch of the wall itself. To turn this
  87.         texture into a wall with a switch, we can add a patch that contains
  88.         only the switch.
  89.  
  90.         What are the limitations?
  91.  
  92.         256 textures. 1024 sectors.  1024 actors. The image data is only
  93.         limited by the amount of ram.
  94.  
  95.  
  96.  
  97.  
  98.         How do I add sound effects?
  99.  
  100.         You provide a function called "PlaySound" that the renderer calls
  101.         when a sound needs to be played. Typically, you would then insert
  102.         the appropriate sound type into some kind of array, that you would
  103.         then process.
  104.  
  105.         How do I Keep score?
  106.  
  107.         Thats up to you!
  108.  
  109.  
  110.  
  111. Using the Renderer
  112.  
  113.         Step1: Initialize the renderer
  114.         Step2: Build Tables for View
  115.         Step3: Load Image Data
  116.         Step4: Add Map Data
  117.  
  118.         After these steps are performed, Call BuildViewBySector to
  119.         generate the view into the buffer pointed to by scrimage.
  120.  
  121.  
  122.          ----------------------------------------------------------------------
  123.          Example:
  124.  
  125.          // This example creates a simple map that contains only one room.
  126.  
  127.          Init4DX();             // Initialize renderer
  128.          BuildTables(320,200);  // Build tables for view
  129.  
  130.          // Add the textures (code not included)
  131.          // Add the flats    (code not included)
  132.  
  133.          // Add the vertexes.
  134.          AddVertex(100,100);
  135.          AddVertex(400,100);
  136.          AddVertex(400,400);
  137.          AddVertex(100,400);
  138.          AddVertex(600,400);
  139.          AddVertex(600,600);
  140.  
  141.          // Add the sector definition(s)
  142.          NewSector (0,1,1,0,128,0,0);
  143.  
  144.          // Add the lines to the sector(s)
  145.          AddLine(0,1,BOUND,1,0,0);
  146.          AddLine(1,2,BOUND,1,0,0);
  147.          AddLine(2,3,BOUND,1,0,0);
  148.          AddLine(3,0,BOUND,1,0,0);
  149.  
  150.          // Add the actor(s)
  151.          AddActor(200,200,0,0,ACTOR_SHOOTABLE,40,40);
  152.  
  153.          // generate a view from actor 0
  154.          for(int i=0;i<100;i++)
  155.             {
  156.             BuildViewBySector(0,0);
  157.             }
  158.  
  159.          ----------------------------------------------------------------------
  160.          Example:
  161.  
  162.          // Making a two sector map.
  163.          // Add the Sectors
  164.          // Note: Please see example source for loading images.
  165.  
  166.          NewSector(0,1,1,0,128,0,0);
  167.          NewSector(1,1,1,20,96,0,0);
  168.  
  169.          // Add Vertexes
  170.          AddVertex(100,100);
  171.          AddVertex(400,100);
  172.          AddVertex(400,400);
  173.          AddVertex(100,400);
  174.          AddVertex(600,400);
  175.          AddVertex(600,600);
  176.  
  177.          // Add lines for first sector (0)
  178.          AddLine(0,1),BOUND,1,0,0);
  179.          AddLine(1,2),BOUND,1,0,1);  // this line connects to sector 1.
  180.          AddLine(2,3),BOUND,1,0,0);
  181.          AddLine(3,0),BOUND,1,0,0);
  182.  
  183.          // Add lines for second sector (1)
  184.          // Notice we did not add the connecting line twice.
  185.          AddLine(1,4,BOUND,1,1,1);
  186.          AddLine(4,5,BOUND,1,1,1);
  187.          AddLine(5,2,BOUND,1,1,1);
  188.  
  189.          // Add the actor(s)
  190.          AddActor(200,200,0,0,ACTOR_SHOOTABLE,40,40);
  191.  
  192.          // generate a view from actor 0
  193.          for(int i=0;i<100;i++)
  194.             {
  195.             BuildViewBySector(0,0);
  196.             }
  197.  
  198. Functions:
  199.  
  200.         Initialization Functions:
  201.         -------------------------
  202.  
  203.         Function:        Init4DX
  204.         Parameters:      None
  205.         Returns:         None
  206.         Description:     Performs one time initialization. Must be called before
  207.                         any other 4DX functions.
  208.  
  209.         Function:        BuildTables
  210.         Parameters:      Width (int), Height (int)
  211.         Returns:         None
  212.         Description:     Creates the appropriate tables for a view that is
  213.                         Width wide, by Height high. Can be called multiple times
  214.                         to change view size.
  215.  
  216.  
  217.  
  218.  
  219.  Texture Functions:
  220.         ------------------
  221.         Function:        AssignBitmap
  222.         Parameters:      index (int), address (unsigned char *),
  223.                         width (int), height (int).
  224.         Returns:         None
  225.         Description:     Adds a bitmap to the bitmap array. This bitmap can later
  226.                         be used as the texture source for an object.
  227.  
  228.         Function:        AssignTexture
  229.         Parameters:      index (int), width (int), height (int)
  230.         Returns:         None
  231.         Description:     Adds a virtual texture to the texture array. Index is the
  232.                         number of the texture (0-255). This function does not
  233.                          actually allocate any space for the texture itself.
  234.                         Patches MUST be added to the texture before it can be
  235.                         used! Textures MUST be powers of 2 wide (ie,16,32,64,128,256 etc).
  236.  
  237.         Function:        AddPatch
  238.         Parameters:      index (int), address(unsigned char *),
  239.                         width (int), height (int), xoffset (int), yoffset (int)
  240.         Returns:         None
  241.         Description:    Adds a patch at ADDRESS to texture number INDEX.
  242.                         Texture must be added before a patch can be added to the
  243.                         texture.Width and height are the dimensions of the patch to
  244.                         add to the texture. xoffset and yoffset are the position to
  245.                             place the patch within the texture. NOTE: Clipping is not
  246.                              performed on patches. The patch MUST fit entirely within
  247.                         the texture.
  248.  
  249.         Function:        AssignFlat
  250.         Parameters:      index (int), address (unsigned char *), mask (int)
  251.         Returns:         None
  252.         Description:     Adds a flat to the flat array. Flats are used for floors
  253.                         ceilings, countertops, etc. INDEX is the number of the
  254.                         flat. Each row of flat data MUST be 256 byte aligned.
  255.                         Please see "LoadFlats" for an example on how to do this.
  256.                         MASK is the AND mask for this, and is required. Normally,
  257.                         the formula is as follows.
  258.  
  259.                         int mask = ((bmw-1)<<8)|(bmw-1);
  260.                         Please note that a flat must be square, and must be a
  261.                         power of 2 wide, ie, 16,32,64,128, or 256.
  262.  
  263.         Map Creation Functions:
  264.  
  265.         Function:        NewSector
  266.         Parameters:      int sector       sector number
  267.                         int top        flat on the floor of this sector
  268.                         int bottom     flat on the cieling of this sector
  269.                         int floorht    the height of the floor
  270.                         int ceilht     the height of the ceiling
  271.                         int offset     the players offset inside this sector
  272.                                        (ie, positive = floating, negative = sunken)
  273.                         int flags      SECTOR_SELFILLUMINATING
  274.                                        SECTOR_SKY
  275.                                        SECTOR_SNOW
  276.                                        SECTOR_RAIN
  277.                                        SECTOR_BOB
  278.                         int x_top      floor movement x direction
  279.                         int y_top      floor movement y direction
  280.                         int x_bottom   ceiling movement x direction
  281.                         int y_bottom   ceiling movement y direction
  282.                         int ltlevel    light level of this sector
  283.         Returns:         None
  284.         Description:     Adds
  285.  
  286.         Function:        AddActor.
  287.         Parameters:      int x            x position on map.
  288.                         int y          y position on map.
  289.                         int angle      angle actor is facing.
  290.                         int flags      ACTOR_PICKUP
  291.                                        ACTOR_WALKOVER
  292.                                        ACTOR_USABLE
  293.                                        ACTOR_CONSUMABLE
  294.                                        ACTOR_AUTOINC
  295.                                        ACTOR_SHOOTABLE
  296.                                        ACTOR_ACTIVE
  297.                         int maxhp      Maximum health of actor.
  298.                         int curhp      Current health of actor.
  299.                         int range      distance that actor can hit from.
  300.                         int damage     damage that actor can do.
  301.                         int dambase    least damage from a hit.
  302.                         int active     whether this actor is active.
  303.         Returns:         None
  304.         Description:     Adds an actor to the actor database. Must be done after
  305.                         sector has been added.
  306.  
  307.         Function:        AddVertex
  308.         Parameters:      int x
  309.                         int y
  310.         Returns:         Vertex Number
  311.         Description:     Adds a vertex to the vertex database. Vertexes for a
  312.                         line must be added before the line is added.
  313.  
  314.         Function:        AddLine
  315.         Parameters:     int fv      index of from vert
  316.                         int tv      index of to vert
  317.                         int flags   BOUND         - there is nothing beyond wall
  318.                                     TRIP_CROSS    - crossing the line "trips"
  319.                                                     something
  320.                                     TRIP_ACTIVATE - pressing space bar or
  321.                                                     mouse button trips something
  322.                                     LINE_EXTENDC  - instead of drawing a top
  323.                                                     wall extend the cieling down
  324.                                     LINE_NOMAP    - don't display on map ever
  325.                                     LINE_SEEN     - this line has been seen
  326.                                     LINE_SKIPCEIL - Dont draw ceiling
  327.                                                     connecting to wall
  328.                                     LINE_MASK     - Color 0 is masked.
  329.                                                     wall cannot be BOUNDED, and
  330.                                                     connecting sector MUST be same
  331.                                                     floor and ceiling height.
  332.                                     LINE_TRANS    - Line is translucent - only
  333.                                                     used with LINE_MASK. Instead of
  334.                                                     being drawn, solid colors are
  335.                                                     translucent over background.
  336.                         int bitmap     Texture number from texture array of bottom
  337.                                        segment. Also whole wall if BOUND
  338.                         int sec        Sector number that this wall is in
  339.                         int tosector   Sector number that this wall faces. if wall
  340.                                        is BOUND, then must be same as SEC
  341.  
  342.                         int trpflags   TRIP_CHANGEFLOOR    Floor of sector in
  343.                                                            trip1 changes TO trip2.
  344.                                        TRIP_CHANGECIELING  Ceiling of sector in
  345.                                                            trip3 changes TO trip4.
  346.                                        TRIP_ONCE           Only trips one time.
  347.                                        TRIP_TELEPORT       Teleport to location.
  348.                                                       trip1 = x
  349.                                                       trip2 = y
  350.                                                       trip3 = height
  351.                                                       trip4 = facing angle
  352.                                        TRIP_FLIP      exchanges bitmap and bitmap2
  353.                                                       and topbm and topbm2.
  354.                                                       useful for switches.
  355.  
  356.                                        TRIP_ROTATESECTOR   rotate a sector around x,y
  357.                                                       trip1 = sector
  358.                                                       trip2 = degrees
  359.                                                       trip3 = x
  360.                                                       trip4 = y
  361.                                           TRIP_UNROTATESECTOR
  362.                                                       See above, except that sector
  363.                                                         moves back to original position
  364.  
  365.                         int bitmap2    exchanges with bitmap when line is flipped.
  366.                         int topbm      Bitmap on ceiling segment.
  367.                         int topbm2     exchanges with topbm when line is flipped.
  368.         Returns:         None
  369.         Description:     Adds a line to a sector. A sector must be fully enclosed
  370.                         by lines, and lines must be entered CLOCKWISE.
  371.  
  372.         Function:        NewLine
  373.         Parameters:      See above.
  374.         Returns:         None
  375.         Description:     Use Addline unless you haven't added your vertexes yet.
  376.                         This function is the same as addline except for passing
  377.                         actual x1,y1,x2,y2 coordinates for the line. vertexes will
  378.                         be created for you. Newline is only included for backward
  379.                         compatability.
  380.  
  381.         Function:        DupeLine
  382.         Parameters:      linedef *aLine     the line to duplicate
  383.                         int      tosector  the sector to place the duplicate in.
  384.         Returns:         None
  385.         Description:     This function welds two sectors together by inserting a
  386.                         duplicate line in a lines facing sector.
  387.  
  388.  
  389.  Runtime Functions:
  390.  
  391.         Function:        BuildViewBySector
  392.         Parameters:      int actor   actor to generate POV from
  393.                         int bob     skew the view up or down by this amount
  394.         Returns:         None
  395.         Description:     Generates a view into buffer at the point of view of
  396.                         the actor.
  397.  
  398.         Function:        CheckEvents
  399.         Parameters:      None
  400.         Returns:         None
  401.         Description:     Must be called once per frame to make sure events happen
  402.  
  403.         Function:        CheckMissiles
  404.         Parameters:      None
  405.         Returns:         None
  406.         Description:     Must be called once per frame to move missiles
  407.  
  408.         Function:        CheckActors
  409.         Parameters:      None
  410.         Returns:         None
  411.         Description:     Must be called once per frame so that gravity acts on actors.
  412.  
  413.         CallBack Functions:
  414.         -------------------
  415.         Note: Your program must provide these functions.
  416.  
  417.         Function:        HandleMessage
  418.         Parameters:      int msg
  419.                         int info
  420.         Returns:         None
  421.         Description:     If msg = MSG_HPCHANGE, then your characters hit points
  422.                         have been changed.
  423.                         if msg = MSG_HITITEM, then your character has ran over
  424.                         an item (item number = info)
  425.  
  426.         Function:        PlaySound
  427.         Parameters:      int soundnum
  428.                         int volume
  429.         Returns:         None
  430.         Description:     Play sound number soundnum at level volume.
  431.  
  432.  
  433.         Useful Objects:
  434.         ---------------
  435.  
  436.         ActorBox     aBox
  437.         Function:        FindBox
  438.         Parameteres:     int x
  439.                         int y
  440.         Returns          int ActorIndex
  441.         Description:     Use this object to determine if a point on a screen
  442.                         is over any actors. For example if the mouse was clicked
  443.                         at 160,100,
  444.                         actr = aBox->FindBox(160,100);
  445.                         if actr is greater than 0, then an actor was clicked on,
  446.                         and you can take the appropriate action.
  447.